#ifndef POST_PROCESS_COMMON_VAR_H
#define POST_PROCESS_COMMON_VAR_H

#include <eigen3/Eigen/Core>

#include "common/basic_type.h"
#include "common/perception_defs.h"

struct SUBUDPData {
  uint8_t id = 0;
  float center_x;
  float center_y;
  float center_z;
  float length;
  float width;
  float height;
  float heading;
  float vx;
  float vy;
  float ax;
  float ay;
  int label;
};

struct UDPData {
  std::uint64_t timestamp;
  autodrive::perception::fixed_array<SUBUDPData, 100> dl_boxes;
  autodrive::perception::fixed_array<SUBUDPData, 100> obstacle;
};

// struct LidarData {
//   quint64 timestamp;
//   Eigen::Vector3f position;  // center point
//   Eigen::Vector3f scale;
//   Eigen::Vector3f rotation;
//   std::array<Point2f, 4> polygen;
//   Eigen::Vector3f velocity;
//   bool velocity_flag = false;//
//   Eigen::Vector3f acceleration;
//   bool accleration_flag = false;//
//   QString type;  // define here
//   int category;
//   int id;
//   quint32 lidar_pts;
//   quint32 radar_pts;
//   float score;
// };

struct Box {
  /// @brief Center
  Eigen::Vector3f center;
  /// @brief length
  float length;
  /// @brief width
  float width;
  /// @brief height
  float height;
  /// @brief polygon
  std::array<Eigen::Vector3f, 4> polygon;
};

/// @brief settings
struct PostProcessorSettings {
  /// @brief ObjectTrack能够存储的最大历史帧数
  int track_cached_history_size_maximum;
  /// @brief 加速度噪声(未用)
  float track_acceleration_noise_maximum;
  /// @brief 速度噪声(未用)
  float track_speed_noise_maximum;
  //// @brief 输出目标的最大不连续的帧数阈值，超过这个数值则不输出obstacle
  int collect_track_consecutive_invisible_maximum;
  //// @brief 输出目标的最小连续帧数阈值，至少要大于这个数值才输出obstacle
  int collect_track_age_minimum;
  //// @brief 初始化协方差P阵中的位置
  float initial_position_noise;
  //// @brief 初始化协方差P阵中的速度
  float initial_velocity_noise;
  //// @brief 初始化协方差P阵中的加速度
  float initial_acceleration_noise;
  //// @brief 初始化Q阵中的状态噪声
  float initial_env_noiose;
  //// @brief match的匹配阈值
  float vehicle_2diou_threshold;
  //// @brief match的匹配阈值
  float vehicle_distance_threshold;
  //// @brief match的匹配阈值
  float pedestrian_2diou_threshold;
  //// @brief match的匹配阈值
  float pedestrian_distance_threshold;
  //// @brief 是否使用kalman的增益限幅
  bool use_kalman_breakdown;
  //// @brief vehicle的距离的kalman增益的阈值
  float vehicle_distance_breakdown_threshold;
  //// @brief vehicle的速度的kalman增益的阈值
  float vehicle_velocity_breakdown_threshold;
  //// @brief vehicle的加速度的kalman增益的阈值
  float vehicle_acceleration_breakdown_threshold;
  //// @brief pedestrian的距离的kalman增益的阈值
  float pedestrian_distance_breakdown_threshold;
  //// @brief pedestrian的速度的kalman增益的阈值
  float pedestrian_velocity_breakdown_threshold;
  //// @brief pedestrian的加速度的kalman增益的阈值
  float pedestrian_acceleration_breakdown_threshold;
  //// @brief motion_kalman的vehivle的Q阵
  std::vector<float> motion_vehicle_Q;
  //// @brief motion_kalman的vehivle的R阵
  std::vector<float> motion_vehicle_R;
  //// @brief motion_kalman的vehivle的Q阵
  std::vector<float> motion_pedestrian_Q;
  //// @brief motion_kalman的vehivle的R阵
  std::vector<float> motion_pedestrian_R;
};

constexpr int objecttrack_cached_history_size_maximum{
    5};  // ObjectTrack能够存储的最大历史帧数

constexpr float objecttrack_acceleration_noise_maximum{0.6f};

constexpr float objecttrack_speed_noise_maximum{5.0f};

constexpr int collect_track_consecutive_invisible_maximum{
    4};  // 输出目标的最大不连续的帧数阈值，超过这个数值则不输出obstacle

constexpr int collect_track_age_minimum{
    5};  // 输出目标的最小连续帧数阈值，至少要大于这个数值才输出obstacle

constexpr float initial_vehicle_position_noise{
    0.5f};  // 初始化协方差P阵中的位置
constexpr float initial_vehicle_velocity_noise{
    0.5f};  // 初始化协方差P阵中的速度
constexpr float initial_vehicle_acceleration_noise{
    1.0f};  // 初始化协方差P阵中的加速度

constexpr float initial_env_noiose{0.5f};  // 初始化Q阵中的状态噪声

#endif
